<template>
  <div class="label-top">


    <el-row :gutter="15">
      <el-col :span="16">
        <el-form ref="form" label-position="top" :model="form" :disabled="true" label-width="80px">
          <el-descriptions title="企业基地"></el-descriptions>
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="企业名称" prop="ebName">
                <el-input v-model="form.ebName" placeholder="请输入企业名称"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="基地名称" prop="ebBaseName">
                <el-input v-model="form.ebBaseName" placeholder="请输入基地名称"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="所在省市" prop="ebAddress">
                <el-cascader
                  :options="regionTree"
                  :props="{ value:'climecode',label:'climename' }"
                  clearable
                  regionTree
                  placeholder="请输入所在省市"
                  v-model="form.ebAddress"
                ></el-cascader>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="状态" prop="ebStatus">
                <el-select v-model="form.ebStatus" placeholder="请输入状态">
                  <el-option
                    v-for="dict in dict.type.base_status"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="投产日期" prop="ebProductionDate">
                <el-date-picker clearable
                                v-model="form.ebProductionDate"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="请选择投产日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="建厂形式" prop="ebFactoryType">
                <el-select v-model="form.ebFactoryType" placeholder="请输入状态">
                  <el-option
                    v-for="dict in dict.type.factory_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="生产线(条)" prop="ebProductionLine">
                <el-input-number el-input-number controls-position="right" :precision="2"   v-model="form.ebProductionLine" placeholder="请输入生产线(条)"/>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="产品固定产能(万台/年)" prop="ebFixedCapacity">
                <el-input-number el-input-number controls-position="right" :precision="2"  v-model="form.ebFixedCapacity" placeholder="请输入产品固定产能(万台/年)"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="满产产能(万台)" prop="ebMaxCapacity">
                <el-input-number el-input-number controls-position="right" :precision="2"  v-model="form.ebMaxCapacity" placeholder="请输入满产产能(万台)"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="现货库存(万台)" prop="ebInventory">
                <el-input-number el-input-number controls-position="right" :precision="2"  v-model="form.ebInventory" placeholder="请输入现货库存(万台)"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="品牌" prop="ebBrand">
                <el-input v-model="form.ebBrand" placeholder="请输入品牌"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="产品形态" prop="ebForm">
                <el-cascader
                  :options="productFormTree"
                  :props="{ multiple: true,value:'code',label:'name' }"
                  collapse-tags
                  clearable
                  placeholder="请输入产品形态"
                  v-model="form.ebForm"
                ></el-cascader>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="技术路线" prop="ebTechnology">
                <el-input type="textarea" v-model="form.ebTechnology" placeholder="请输入技术路线" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="备注" prop="remark">
                <el-input type="textarea" v-model="form.remark" placeholder="请输入备注"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-descriptions title="年度产能(万台)"></el-descriptions>
          <el-row :gutter="15">

            <el-col :span="12">
              <el-form-item label="年度产能(万台)当前年" prop="ebCurrentCapacity">
                <el-input-number  el-input-number controls-position="right" :precision="2"  v-model="form.ebCurrentCapacity" placeholder="请输入年度产能(万台)当前年"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="年度产能(万台)下一年" prop="ebNextRoadmap">
                <el-input-number  el-input-number controls-position="right" :precision="2" v-model="form.ebNextRoadmap" placeholder="请输入年度产能(万台)下一年"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-col>
      <el-col :span="8">
        <el-descriptions title="审核记录"></el-descriptions>
        <div class="block">
          <el-timeline>
            <el-timeline-item
              v-for="item in auditingList"
              :key="item.id"
              :timestamp="item.createTime"
              :type="item.aState === '1'?'danger':'success'"

              placement="top">
              <el-card>
                <div slot="header" class="clearfix">
                  {{ item.createBy }}
                </div>
                <p> {{item.aInfo}}</p>
              </el-card>
            </el-timeline-item>
          </el-timeline>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import EditMixin from "@/minixs/edit"
import request from "@/utils/request";
import {listProductForm} from "@/api/info/productForm";
import {listRegion} from "@/api/info/region";
export default {
  name: "detail",
  mixins:[EditMixin],
  dicts:['base_status','factory_type'],
  data() {
    return {
      // 审核列表
      auditingList:[],
      // 地区选择
      regionTree:[],
      // 产品形态
      productFormTree: [],
      // 表单数据
      form: {
        id: null,
        ebName: null,
        ebBaseName: null,
        ebAddress: null,
        ebStatus: null,
        ebProductionDate: null,
        ebFactoryType: null,
        ebProductionLine: null,
        ebFixedCapacity: null,
        ebMaxCapacity: null,
        ebInventory: null,
        ebBrand: null,
        ebForm: null,
        ebCurrentCapacity: null,
        ebNextRoadmap: null,
        delFlag: null,
        createBy: null,
        updateBy: null,
        createTime: null,
        updateTime: null,
        remark: null
      },
    }
  },
  created() {
    listProductForm(this.queryParams).then(response => {
      this.productFormTree = this.handleTree(response.data, "code", "pcode");
    });
    listRegion(this.queryParams).then(response => {
      this.cityMap = {}
      response.data.forEach(item=>{
        this.cityMap[item.climecode] = item
      })
      this.regionTree = this.handleTree(response.data, "climecode", "pcode");
    });
  },
  mounted() {
    request({
      url: '/info/base/' + this.id,
      method: 'get'
    }).then(res=>{
      const form = res.data;
      form.ebForm = form.ebForm.split("#").map(item=>{
        return item.split(",")
      });
      form.ebAddress = form.ebAddress.split(",");
      this.form = form;
    });


    request({
      url: '/info/auditing/list',
      method: 'get',
      params: {
        pageNum: 1,
        pageSize: 100,
        aPId:this.id,
        pName:"enterprise_base"
      }
    }).then(response => {
      this.auditingList = response.rows;
    });
  },
};
</script>
